//
//  ClearPriceModel.m
//  quickBatchManager
//
//  Created by 王定波 on 15/10/14.
//  Copyright © 2015年 jack. All rights reserved.
//

#import "ClearPriceModel.h"
#import "UploadData.h"
@implementation ClearPriceModel
+(NSString *)getTableName
{
    return @"qbm_clearPrice";
}

+(NSString *)getPrimaryKey
{
    return @"t_id";
}

+(void)dbDidInserted:(NSObject*)entity result:(BOOL)result
{
    if([entity isKindOfClass:[ClearPriceModel class]])
    {
        ClearPriceModel *model = (ClearPriceModel *)entity;
        UploadData *data = [[UploadData alloc] init];
        data.t_table = [ClearPriceModel getTableName];
        data.t_opType = DB_INSERT;
        data.t_pkName = [self getPrimaryKey];
        data.t_pk = model.rowid;
        data.t_time = [[NSDate date] timeIntervalSince1970InMilliSecond];
         model.t_id = data.t_pk;
        NSString *value = [self DataTOjsonString:model.keyValues];
        data.content = value;
        [UploadData insertToDB:data];
    }
//    NSLog(@"DB 插入数据成功");
    
    
}

+(void)dbDidUpdated:(NSObject*)entity result:(BOOL)result
{
    if([entity isKindOfClass:[ClearPriceModel class]])
    {
        ClearPriceModel *model = (ClearPriceModel *)entity;
        UploadData *data = [[UploadData alloc] init];
        data.t_table = [ClearPriceModel getTableName];
        data.t_opType = DB_UPDATE;
        data.t_pkName = [self getPrimaryKey];
        data.t_pk = model.rowid;
        data.t_time = [[NSDate date] timeIntervalSince1970InMilliSecond];
         model.t_id = data.t_pk;
        NSString *value = [self DataTOjsonString:model.keyValues];
        data.content = value;
        [UploadData insertToDB:data];
    }
  //  NSLog(@"DB 更新数据");
}


+(void)dbDidDeleted:(NSObject*)entity result:(BOOL)result
{
    if([entity isKindOfClass:[ClearPriceModel class]])
    {
        ClearPriceModel *model = (ClearPriceModel *)entity;
        UploadData *data = [[UploadData alloc] init];
        data.t_table = [ClearPriceModel getTableName];
        data.t_opType = DB_DELETE;
        data.t_pkName = [self getPrimaryKey];
        data.t_pk = model.rowid;
        model.t_id = data.t_pk;
        data.t_time = [[NSDate date] timeIntervalSince1970InMilliSecond];
        NSString *value = [self DataTOjsonString:model.keyValues];
        data.content = value;
        [UploadData insertToDB:data];
    }
  //  NSLog(@"DB 删除数据");
}
@end
